package com.guli.common.utils;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class ResultData<T> implements Serializable {
    private Integer count;
    private Integer pageSize;
    private Integer code = 200;
    private String msg = "success";
    private T data;

    public static <T> ResultData<T> ok(T data) {
        ResultData resultData = new ResultData();
        resultData.setData(data);
        return resultData;
    }

    public static <T> ResultData<T> fail(Integer code, String message) {
        ResultData resultData = new ResultData();
        resultData.setCode(code);
        resultData.setMsg(message);
        return resultData;
    }
}
